var mongoose = require('mongoose')
var nodemailer = require('nodemailer')
var Mongoose = {
  url: 'mongodb://localhost:27017/selfserver',
  connect () {
    mongoose.connect(this.url, { useNewUrlParser: true }, (err) => {
      if (err) {
        console.log('数据库连接失败')
      }
      console.log('数据库连接成功')
    })
  }
}
var Email = {
  config: {
    host: 'smtp.qq.com',
    port: 587,
    secure: false,
    auth: {
      user: '1203486487@qq.com',
      pass: 'vbiyxtndjehvhfcb'
    }
  },
  get transporter () {
    return nodemailer.createTransport(this.config)
  },
  get verify () {
    return Math.random().toString().substring(2, 6)
  }
}

module.exports = {
  Mongoose,
  Email
}
